import { Callout } from "nextra/components";
import VideoEmbed from "../../components/video-embed";

# Land Cover Classification

> Classify land cover types in satellite imagery

<VideoEmbed
  src="https://geobase-docs.s3.amazonaws.com/geobase-ai-assets/land-cover-classification.mp4"
  title="Land Cover Classification Demo"
/>

<div style={{ textAlign: 'center', marginTop: '1rem' }}>
  <a 
    href="https://docs.geobase.app/geoai-live/tasks/land-cover-classification" 
    target="_blank" 
    rel="noopener noreferrer"
    style={{ 
      display: 'inline-flex', 
      alignItems: 'center', 
      gap: '0.5rem',
      padding: '0.5rem 1rem',
      backgroundColor: '#3b82f6',
      color: 'white',
      textDecoration: 'none',
      borderRadius: '0.375rem',
      fontWeight: '500',
      transition: 'background-color 0.2s'
    }}
    className="live-demo-button"
  >
    🚀 Try Live Demo
  </a>
</div>

<style jsx>{`
  .live-demo-button:hover {
    background-color: #2563eb !important;
  }
`}</style>

<div style={{ textAlign: 'center', marginTop: '0.5rem' }}>
  <a 
    href="https://huggingface.co/geobase/sparsemask" 
    target="_blank" 
    rel="noopener noreferrer"
    style={{ 
      fontSize: '0.875rem',
      color: '#6b7280',
      textDecoration: 'none'
    }}
  >
    🤗 View Model on Hugging Face
  </a>
</div>

## Quick Start

```typescript
import { geoai } from "geoai";

// Initialize pipeline
const pipeline = await geoai.pipeline(
  [{ task: "land-cover-classification" }],
  providerParams
);

// Run classification
const result = await pipeline.inference({
  inputs: { polygon: myPolygon },
  postProcessingParams: { minArea: 20 },
});

console.log(
  `Classified ${result.classifications.features.length} land cover areas`
);
```

<Callout type="info" emoji="🌍">
  Classifies regions into 8 land cover types: forest, agriculture, urban, water,
  roads, rangeland, bareland, and buildings
</Callout>

## Parameters

### Post-Processing

```typescript
postProcessingParams: {
  minArea: 20; // Minimum area threshold for classification polygons
}
```

### Map Source

```typescript
mapSourceParams: {
  zoomLevel: 15; // 14-16 recommended for land cover analysis
}
```

## Land Cover Classes

| Class              |
| ------------------ |
| `tree`             |
| `agriculture land` |
| `developed space`  |
| `water`            |
| `road`             |
| `rangeland`        |
| `bareland`         |
| `buildings`        |

## Output

Returns a list of GeoJSON FeatureCollections (one for each land cover class):

```typescript
{
  geoRawImage : GeoRawImage, // Inference image
  outPutImage : GeoRawImage, // combined masks
  binaryMasks : RawImage // binary mask for each class
  detections: [   // list of FeatureCollection
    {
      type: "FeatureCollection",
      features: [
        {
          geometry: { /* tree polygon */ },
          properties: {
            class: "tree"
          }
        }
      ]
    },
    {
      type: "FeatureCollection",
      features: [
        {
          geometry: { /* agriculture polygon */ },
          properties: {
            class: "agriculture land"
          }
        }
      ]
    }
    // ... one FeatureCollection for each detected land cover class
  ]
}
```
